package com.sleepless.my.repository;

import com.sleepless.my.entity.VideoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VideoRepository extends JpaRepository<VideoEntity, Integer>, JpaSpecificationExecutor<VideoEntity> {
    @Query(value = "SELECT video_id FROM `video_entity` ORDER BY RAND() LIMIT :limit", nativeQuery = true)
    List<Integer> findRandomIds(@Param("limit") int limit);
}
